/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Presentacion;

import Datos.Conexion;
import Datos.Global;
import Killer.jMessageFlush;
import Negocio.clsCategoria;
import Negocio.clsProveedor;
import Negocio.clsProveedor_insumo;
import Negocio.clsTelefono;
import java.awt.Color;
import java.util.ArrayList;
import java.util.List;
import javax.swing.ImageIcon;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author RODRIGO
 */
public class frmProveedor extends javax.swing.JDialog {

    public static List<String> listaRubros;
    public static int idProveedor, fila;
    Conexion conn = new Conexion();
    boolean isHabilitado = false;
    private ImageIcon imageIcon_empty;
    private ImageIcon imageIcon_medium;
    private ImageIcon imageIcon_complete;

    public frmProveedor(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        this.setTitle("Proveedor");
        this.setLocationRelativeTo(null);
        this.cargarProveedores();
        this.deshabilitarCampos();
        listaRubros = new ArrayList<>();

        imageIcon_complete = new ImageIcon(getClass().getResource("/imagenes/estrellaComplete.png"));
        imageIcon_medium = new ImageIcon(getClass().getResource("/imagenes/estrellaMedium.png"));
        imageIcon_empty = new ImageIcon(getClass().getResource("/imagenes/estrellaEmpty.png"));
        
        

    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        panel1 = new org.edisoncor.gui.panel.Panel();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        txtNombre_Empresa = new javax.swing.JTextField();
        txtDireccion = new javax.swing.JTextField();
        txtNro_Cuenta = new javax.swing.JTextField();
        txtEmail = new javax.swing.JTextField();
        txtNombre_Contacto = new javax.swing.JTextField();
        stars1 = new javax.swing.JLabel();
        btnAgregarTelefono = new javax.swing.JButton();
        stars2 = new javax.swing.JLabel();
        stars3 = new javax.swing.JLabel();
        stars4 = new javax.swing.JLabel();
        stars5 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        btnAgregarRubro = new javax.swing.JButton();
        cbxCiudad = new javax.swing.JComboBox();
        cbxRubro = new javax.swing.JComboBox();
        cbxTelefono = new javax.swing.JComboBox();
        lbObligatorio1 = new javax.swing.JLabel();
        lbObligatorio2 = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        lblVerProveedorDeshabilitado = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jToolBar1 = new javax.swing.JToolBar();
        btnNuevo = new javax.swing.JButton();
        btnModificar = new javax.swing.JButton();
        btnGuardar = new javax.swing.JButton();
        btnEliminar = new javax.swing.JButton();
        btnCancelar = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        cbxCategoria = new javax.swing.JComboBox();
        txtBuscador = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        tbProveedores = new javax.swing.JTable();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setBackground(java.awt.Color.yellow);
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                cerraVentanaProveedor(evt);
            }
        });

        panel1.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        panel1.setAutoscrolls(true);
        panel1.setColorPrimario(new java.awt.Color(255, 255, 153));
        panel1.setColorSecundario(new java.awt.Color(255, 255, 153));

        jPanel1.setBackground(new java.awt.Color(255, 255, 153));
        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Datos relacionados al proveedor", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Cambria", 1, 14))); // NOI18N

        jLabel1.setFont(new java.awt.Font("Cambria", 0, 14)); // NOI18N
        jLabel1.setText("Nombre empresa:");

        jLabel2.setFont(new java.awt.Font("Cambria", 0, 14)); // NOI18N
        jLabel2.setText("Direccion:");

        jLabel3.setFont(new java.awt.Font("Cambria", 0, 14)); // NOI18N
        jLabel3.setText("Ciudad:     ");

        jLabel4.setFont(new java.awt.Font("Cambria", 0, 14)); // NOI18N
        jLabel4.setText("Nro. Cuenta:     ");

        jLabel5.setFont(new java.awt.Font("Cambria", 0, 14)); // NOI18N
        jLabel5.setText("Email:      ");

        jLabel6.setFont(new java.awt.Font("Cambria", 0, 14)); // NOI18N
        jLabel6.setText("Nombre contacto:     ");

        jLabel7.setFont(new java.awt.Font("Cambria", 0, 14)); // NOI18N
        jLabel7.setText("Telefono:     ");

        txtNombre_Empresa.setFont(new java.awt.Font("Cambria", 0, 14)); // NOI18N
        txtNombre_Empresa.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                txtNombre_EmpresaMouseClicked(evt);
            }
        });
        txtNombre_Empresa.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtNombre_EmpresaKeyTyped(evt);
            }
        });

        txtDireccion.setFont(new java.awt.Font("Cambria", 0, 14)); // NOI18N
        txtDireccion.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                txtDireccionMouseClicked(evt);
            }
        });
        txtDireccion.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtDireccionKeyTyped(evt);
            }
        });

        txtNro_Cuenta.setFont(new java.awt.Font("Cambria", 0, 14)); // NOI18N
        txtNro_Cuenta.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtNro_CuentaKeyTyped(evt);
            }
        });

        txtEmail.setFont(new java.awt.Font("Cambria", 0, 14)); // NOI18N

        txtNombre_Contacto.setFont(new java.awt.Font("Cambria", 0, 14)); // NOI18N
        txtNombre_Contacto.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtNombre_ContactoKeyTyped(evt);
            }
        });

        stars1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/estrellaEmpty.png"))); // NOI18N

        btnAgregarTelefono.setFont(new java.awt.Font("Cambria", 0, 14)); // NOI18N
        btnAgregarTelefono.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/telefono.png"))); // NOI18N
        btnAgregarTelefono.setText("Agregar");
        btnAgregarTelefono.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAgregarTelefonoActionPerformed(evt);
            }
        });

        stars2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/estrellaEmpty.png"))); // NOI18N

        stars3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/estrellaEmpty.png"))); // NOI18N

        stars4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/estrellaEmpty.png"))); // NOI18N

        stars5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/estrellaEmpty.png"))); // NOI18N

        jLabel14.setFont(new java.awt.Font("Cambria", 0, 14)); // NOI18N
        jLabel14.setText("Rubro:     ");

        btnAgregarRubro.setFont(new java.awt.Font("Cambria", 0, 14)); // NOI18N
        btnAgregarRubro.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/agregarT.png"))); // NOI18N
        btnAgregarRubro.setText("Agregar");
        btnAgregarRubro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAgregarRubroActionPerformed(evt);
            }
        });

        cbxCiudad.setFont(new java.awt.Font("Cambria", 0, 14)); // NOI18N
        cbxCiudad.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Santa Cruz", "Cochabamba", "La Paz", "Tarija", "Beni", "Pando", "Oruro", "Potosí", "Chuquisaca" }));

        cbxRubro.setFont(new java.awt.Font("Cambria", 0, 14)); // NOI18N

        cbxTelefono.setFont(new java.awt.Font("Cambria", 0, 14)); // NOI18N

        lbObligatorio1.setFont(new java.awt.Font("Cambria", 1, 14)); // NOI18N
        lbObligatorio1.setForeground(new java.awt.Color(255, 0, 0));
        lbObligatorio1.setText("*");

        lbObligatorio2.setFont(new java.awt.Font("Cambria", 1, 14)); // NOI18N
        lbObligatorio2.setForeground(new java.awt.Color(255, 0, 0));
        lbObligatorio2.setText("*");

        jPanel4.setBackground(new java.awt.Color(255, 255, 153));
        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Opciones", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Cambria", 0, 12))); // NOI18N
        jPanel4.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseMoved(java.awt.event.MouseEvent evt) {
                jPanel4MouseMoved(evt);
            }
        });

        lblVerProveedorDeshabilitado.setFont(new java.awt.Font("Cambria", 1, 12)); // NOI18N
        lblVerProveedorDeshabilitado.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblVerProveedorDeshabilitado.setText("Ver proveedores deshabilitados");
        lblVerProveedorDeshabilitado.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        lblVerProveedorDeshabilitado.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                lblVerProveedorDeshabilitadoMouseClicked(evt);
            }
        });
        lblVerProveedorDeshabilitado.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseMoved(java.awt.event.MouseEvent evt) {
                lblVerProveedorDeshabilitadoMouseMoved(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblVerProveedorDeshabilitado, javax.swing.GroupLayout.PREFERRED_SIZE, 241, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblVerProveedorDeshabilitado, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(44, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(lbObligatorio1, javax.swing.GroupLayout.PREFERRED_SIZE, 12, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(lbObligatorio2, javax.swing.GroupLayout.PREFERRED_SIZE, 12, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 165, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 165, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 165, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 165, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 165, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 165, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(36, 36, 36)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(cbxRubro, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(cbxTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(btnAgregarRubro)
                                    .addComponent(btnAgregarTelefono)))
                            .addComponent(txtNombre_Contacto, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 270, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtEmail, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 270, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtNro_Cuenta, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 270, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cbxCiudad, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 270, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtDireccion, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 270, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtNombre_Empresa, javax.swing.GroupLayout.PREFERRED_SIZE, 270, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(stars1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(stars2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(stars3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(stars4, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(stars5)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(3, 3, 3)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(txtNombre_Empresa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel1)
                        .addComponent(lbObligatorio1)))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(6, 6, 6)
                        .addComponent(txtDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2)
                            .addComponent(lbObligatorio2))))
                .addGap(12, 12, 12)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cbxCiudad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel4)
                    .addComponent(txtNro_Cuenta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtNombre_Contacto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6))
                .addGap(9, 9, 9)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cbxTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnAgregarTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7))
                .addGap(8, 8, 8)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnAgregarRubro, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(cbxRubro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel14)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(stars2)
                        .addComponent(stars3)
                        .addComponent(stars4)
                        .addComponent(stars5)
                        .addComponent(stars1))
                    .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jPanel3.setBackground(new java.awt.Color(255, 102, 102));

        jToolBar1.setFloatable(false);
        jToolBar1.setOrientation(javax.swing.SwingConstants.VERTICAL);
        jToolBar1.setRollover(true);

        btnNuevo.setFont(new java.awt.Font("Cambria", 1, 14)); // NOI18N
        btnNuevo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/add.png"))); // NOI18N
        btnNuevo.setText("Nuevo");
        btnNuevo.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        btnNuevo.setFocusable(false);
        btnNuevo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnNuevo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnNuevo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNuevoActionPerformed(evt);
            }
        });
        jToolBar1.add(btnNuevo);

        btnModificar.setFont(new java.awt.Font("Cambria", 1, 14)); // NOI18N
        btnModificar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/refresh.png"))); // NOI18N
        btnModificar.setText("Modificar");
        btnModificar.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        btnModificar.setFocusable(false);
        btnModificar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnModificar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnModificar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnModificarActionPerformed(evt);
            }
        });
        jToolBar1.add(btnModificar);

        btnGuardar.setFont(new java.awt.Font("Cambria", 1, 14)); // NOI18N
        btnGuardar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/save.png"))); // NOI18N
        btnGuardar.setText("Guardar");
        btnGuardar.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        btnGuardar.setFocusable(false);
        btnGuardar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnGuardar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGuardarActionPerformed(evt);
            }
        });
        jToolBar1.add(btnGuardar);

        btnEliminar.setFont(new java.awt.Font("Cambria", 1, 14)); // NOI18N
        btnEliminar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/delete.png"))); // NOI18N
        btnEliminar.setText("Eliminar");
        btnEliminar.setFocusable(false);
        btnEliminar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnEliminar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnEliminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEliminarActionPerformed(evt);
            }
        });
        jToolBar1.add(btnEliminar);

        btnCancelar.setFont(new java.awt.Font("Cambria", 1, 14)); // NOI18N
        btnCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/remove.png"))); // NOI18N
        btnCancelar.setText("Cancelar");
        btnCancelar.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        btnCancelar.setFocusable(false);
        btnCancelar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnCancelar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarActionPerformed(evt);
            }
        });
        jToolBar1.add(btnCancelar);

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        jPanel2.setBackground(new java.awt.Color(255, 255, 153));
        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Cambria", 1, 14))); // NOI18N

        cbxCategoria.setFont(new java.awt.Font("Cambria", 0, 14)); // NOI18N
        cbxCategoria.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Ver Todos" }));
        cbxCategoria.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbxCategoriaActionPerformed(evt);
            }
        });

        txtBuscador.setFont(new java.awt.Font("Cambria", 0, 14)); // NOI18N
        txtBuscador.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtBuscadorKeyReleased(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtBuscadorKeyTyped(evt);
            }
        });

        jLabel15.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/lupa.png"))); // NOI18N

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(cbxCategoria, javax.swing.GroupLayout.PREFERRED_SIZE, 203, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(txtBuscador, javax.swing.GroupLayout.PREFERRED_SIZE, 283, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel15)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(cbxCategoria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(txtBuscador, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel15))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        tbProveedores.setBackground(new java.awt.Color(102, 255, 102));
        tbProveedores.setFont(new java.awt.Font("Cambria", 0, 14)); // NOI18N
        tbProveedores.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "idProveedor", "Nombre empresa", "Dirección", "Ciudad", "email", "nroCuenta", "contacto", "valoracion", "null", "null"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                true, false, false, false, true, true, true, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tbProveedores.setRowHeight(20);
        tbProveedores.setSelectionBackground(new java.awt.Color(0, 102, 0));
        tbProveedores.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        tbProveedores.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tbProveedoresMouseClicked(evt);
            }
        });
        jScrollPane2.setViewportView(tbProveedores);
        tbProveedores.getColumnModel().getColumn(0).setMinWidth(0);
        tbProveedores.getColumnModel().getColumn(0).setPreferredWidth(0);
        tbProveedores.getColumnModel().getColumn(0).setMaxWidth(0);
        tbProveedores.getColumnModel().getColumn(1).setPreferredWidth(150);
        tbProveedores.getColumnModel().getColumn(2).setPreferredWidth(150);
        tbProveedores.getColumnModel().getColumn(3).setPreferredWidth(100);
        tbProveedores.getColumnModel().getColumn(4).setMinWidth(0);
        tbProveedores.getColumnModel().getColumn(4).setPreferredWidth(0);
        tbProveedores.getColumnModel().getColumn(4).setMaxWidth(0);
        tbProveedores.getColumnModel().getColumn(5).setMinWidth(0);
        tbProveedores.getColumnModel().getColumn(5).setPreferredWidth(0);
        tbProveedores.getColumnModel().getColumn(5).setMaxWidth(0);
        tbProveedores.getColumnModel().getColumn(6).setMinWidth(0);
        tbProveedores.getColumnModel().getColumn(6).setPreferredWidth(0);
        tbProveedores.getColumnModel().getColumn(6).setMaxWidth(0);
        tbProveedores.getColumnModel().getColumn(7).setMinWidth(0);
        tbProveedores.getColumnModel().getColumn(7).setPreferredWidth(0);
        tbProveedores.getColumnModel().getColumn(7).setMaxWidth(0);
        tbProveedores.getColumnModel().getColumn(8).setMinWidth(0);
        tbProveedores.getColumnModel().getColumn(8).setPreferredWidth(0);
        tbProveedores.getColumnModel().getColumn(8).setMaxWidth(0);
        tbProveedores.getColumnModel().getColumn(9).setMinWidth(0);
        tbProveedores.getColumnModel().getColumn(9).setPreferredWidth(0);
        tbProveedores.getColumnModel().getColumn(9).setMaxWidth(0);

        javax.swing.GroupLayout panel1Layout = new javax.swing.GroupLayout(panel1);
        panel1.setLayout(panel1Layout);
        panel1Layout.setHorizontalGroup(
            panel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panel1Layout.createSequentialGroup()
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(panel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jScrollPane2)
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        panel1Layout.setVerticalGroup(
            panel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2))
            .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(panel1Layout.createSequentialGroup()
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(panel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(panel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnAgregarTelefonoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAgregarTelefonoActionPerformed

        new frmTelefono(null, true).setVisible(true);
    }//GEN-LAST:event_btnAgregarTelefonoActionPerformed

    private void btnAgregarRubroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAgregarRubroActionPerformed
        listaRubros.clear();
        cbxRubro.removeAllItems();
        new frmRubro(null, true).setVisible(true);
        this.cargarComboBoxRubro();
    }//GEN-LAST:event_btnAgregarRubroActionPerformed

    private void btnNuevoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNuevoActionPerformed
        this.habilitarCampos();
        this.borrarCampos();
        this.pintaEstrellas((float) 0.0);
        String nombre_empresa = " ";
        String direccion = " ";
        float valoracion = (float) 0.0;
        String ciudad = " ";
        String nroCuenta = " ";
        String contacto = " ";
        String email = " ";

        clsProveedor.insertar_Proveedor(nombre_empresa, direccion, valoracion, ciudad, nroCuenta, contacto, email);
        idProveedor = clsProveedor.obtener_idProveedor();
        isHabilitado = true;
        lbObligatorio1.setVisible(true);
        lbObligatorio2.setVisible(true);
    }//GEN-LAST:event_btnNuevoActionPerformed

    private void btnGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGuardarActionPerformed
        String nombreEmpres = Global.enFormato(txtNombre_Empresa.getText());
        String direccion = Global.enFormato(txtDireccion.getText());
        float valoracion = 0;
        String ciudad = cbxCiudad.getSelectedItem().toString();
        String nroCuenta = txtNro_Cuenta.getText();
        String nombContacto = Global.enFormato(txtNombre_Contacto.getText());
        String email = txtEmail.getText();

        if (!nombreEmpres.equals("") && !direccion.equals("")) {   // si no hay campos obligatorios
            clsProveedor.modificar_Proveedor(idProveedor, nombreEmpres, direccion, valoracion, ciudad, nroCuenta, nombContacto, email);
            jMessageFlush.showMessageFlush("Proveedor Guardado Correctamente", jMessageFlush.shortTime, jMessageFlush.Confirmation);
            this.agregar_aTablaProveedores(idProveedor, nombreEmpres, direccion, ciudad, email, nroCuenta, nombContacto, valoracion);
            this.borrarCampos();
            this.deshabilitarCampos();
            isHabilitado = false;
        } else {
            lbObligatorio1.setVisible(txtNombre_Empresa.getText().equals("") ? true : false);
            lbObligatorio2.setVisible(txtDireccion.getText().equals("") ? true : false);

            jMessageFlush.showMessageFlush("Existen campos obligatorios", jMessageFlush.shortTime, jMessageFlush.Warning);
        }
    }//GEN-LAST:event_btnGuardarActionPerformed

    private void tbProveedoresMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tbProveedoresMouseClicked
        if (isHabilitado) {
            clsProveedor.eliminar_proveedor(idProveedor);
            btnCancelar.setEnabled(false);
            btnGuardar.setEnabled(false);
            btnNuevo.setEnabled(true);
            isHabilitado = false;
        }

        fila = tbProveedores.rowAtPoint(evt.getPoint());
        idProveedor = (int) tbProveedores.getValueAt(fila, 0);
        String nombreEmpresa = (String) tbProveedores.getValueAt(fila, 1);
        String direccion = (String) tbProveedores.getValueAt(fila, 2);
        String ciudad = (String) tbProveedores.getValueAt(fila, 3);
        String email = (String) tbProveedores.getValueAt(fila, 4);
        String nroCuenta = (String) tbProveedores.getValueAt(fila, 5);
        String contacto = (String) tbProveedores.getValueAt(fila, 6);
        float valoracion = (float) tbProveedores.getValueAt(fila, 7);

        txtNombre_Empresa.setText(nombreEmpresa);
        txtDireccion.setText(direccion);
        cbxCiudad.setSelectedItem(ciudad);
        txtEmail.setText(email);
        txtNro_Cuenta.setText(nroCuenta);
        txtNombre_Contacto.setText(contacto);
        cbxTelefono.removeAllItems();
        cbxRubro.removeAllItems();
        clsTelefono.cargarListaTelefonos(cbxTelefono, idProveedor);
        clsProveedor_insumo.cargar_listaRubro(idProveedor);
        this.cargarComboBoxRubro();
        this.pintaEstrellas(valoracion);

        this.habilitarCampos();
        btnModificar.setEnabled(true);
        btnNuevo.setEnabled(true);
        btnGuardar.setEnabled(false);
        btnCancelar.setEnabled(false);
        btnEliminar.setEnabled(true);
        lbObligatorio1.setVisible(false);
        lbObligatorio2.setVisible(false);

    }//GEN-LAST:event_tbProveedoresMouseClicked

    private void btnModificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnModificarActionPerformed
        String nombreEmpres = txtNombre_Empresa.getText();
        String direccion = txtDireccion.getText();
        float valoracion = 0;
        String ciudad = cbxCiudad.getSelectedItem().toString();
        String nroCuenta = txtNro_Cuenta.getText();
        String nombContacto = txtNombre_Contacto.getText();
        String email = txtEmail.getText();

        if (!nombreEmpres.equals("") && !direccion.equals("")) {
            clsProveedor.modificar_Proveedor(idProveedor, nombreEmpres, direccion, valoracion, ciudad, nroCuenta, nombContacto, email);
            jMessageFlush.showMessageFlush("Proveedor Modificado Correctamente", jMessageFlush.shortTime, jMessageFlush.Confirmation);
            lbObligatorio1.setVisible(false);
            lbObligatorio2.setVisible(false);

            //modificar los datos de la tabla
            tbProveedores.setValueAt(idProveedor, fila, 0);
            tbProveedores.setValueAt(nombreEmpres, fila, 1);
            tbProveedores.setValueAt(direccion, fila, 2);
            tbProveedores.setValueAt(ciudad, fila, 3);
            tbProveedores.setValueAt(email, fila, 4);
            tbProveedores.setValueAt(nroCuenta, fila, 5);
            tbProveedores.setValueAt(nombContacto, fila, 6);
            tbProveedores.setValueAt(valoracion, fila, 7);
        } else {
            lbObligatorio1.setVisible(txtNombre_Empresa.getText().equals("") ? true : false);
            lbObligatorio2.setVisible(txtDireccion.getText().equals("") ? true : false);

            jMessageFlush.showMessageFlush("Existen campos obligatorios", jMessageFlush.shortTime, jMessageFlush.Warning);
        }
        isHabilitado = false;
    }//GEN-LAST:event_btnModificarActionPerformed

    private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed
        clsProveedor.eliminar_proveedor(idProveedor);
        this.borrarCampos();
        btnCancelar.setEnabled(false);
        btnGuardar.setEnabled(false);
        btnNuevo.setEnabled(true);
        isHabilitado = false;
        lbObligatorio1.setVisible(false);
        lbObligatorio2.setVisible(false);
    }//GEN-LAST:event_btnCancelarActionPerformed

    private void txtBuscadorKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtBuscadorKeyTyped
    }//GEN-LAST:event_txtBuscadorKeyTyped

    private void cbxCategoriaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbxCategoriaActionPerformed
        if (clsCategoria.isHabilitado) {
            String nombreCategoria = cbxCategoria.getSelectedItem().toString();
            String sql;
            if (!nombreCategoria.equals("Ver Todos")) {
                sql = "CALL `buscador_Proveedor`(" + "''" + "," + '"' + nombreCategoria + '"' + "," + 0 + ")";
            } else {
                sql = "CALL `buscador_Proveedor`("+"'','',"+3+")";
            }
            clsProveedor.mostrarTablaProveedores(tbProveedores, sql);
        }
    }//GEN-LAST:event_cbxCategoriaActionPerformed

    private void cerraVentanaProveedor(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_cerraVentanaProveedor
        if (isHabilitado) {
            clsProveedor.eliminar_proveedor(idProveedor);
            clsProveedor_insumo.eliminarProveedor_insumo1(idProveedor);
        }

    }//GEN-LAST:event_cerraVentanaProveedor

    private void txtNombre_EmpresaKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtNombre_EmpresaKeyTyped

        lbObligatorio1.setVisible((txtNombre_Empresa.getText().equals("")) ? true : false);
    }//GEN-LAST:event_txtNombre_EmpresaKeyTyped

    private void txtNro_CuentaKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtNro_CuentaKeyTyped
        Global.validarNumero(20, evt, txtNro_Cuenta);
    }//GEN-LAST:event_txtNro_CuentaKeyTyped

    private void txtDireccionKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtDireccionKeyTyped

        lbObligatorio2.setVisible((txtDireccion.getText().equals("")) ? true : false);
    }//GEN-LAST:event_txtDireccionKeyTyped

    private void txtNombre_ContactoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtNombre_ContactoKeyTyped
        Global.validarLetra(50, evt, txtNombre_Contacto);
    }//GEN-LAST:event_txtNombre_ContactoKeyTyped

    private void txtNombre_EmpresaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_txtNombre_EmpresaMouseClicked

        lbObligatorio1.setVisible((txtNombre_Empresa.getText().equals("")) ? true : false);
    }//GEN-LAST:event_txtNombre_EmpresaMouseClicked

    private void txtDireccionMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_txtDireccionMouseClicked

        lbObligatorio2.setVisible((txtDireccion.getText().equals("")) ? true : false);
    }//GEN-LAST:event_txtDireccionMouseClicked

    private void btnEliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEliminarActionPerformed
        if (tbProveedores.getRowCount() > 0) {
            clsProveedor.deshabilitar_proveedor(idProveedor, "deshabilitado");

            DefaultTableModel dtmLista = (DefaultTableModel) tbProveedores.getModel();
            dtmLista.removeRow(fila);


            this.deshabilitarCampos();
            this.borrarCampos();
            cbxRubro.removeAllItems();
            cbxTelefono.removeAllItems();
            btnEliminar.setEnabled(false);
            btnModificar.setEnabled(false);
        }
    }//GEN-LAST:event_btnEliminarActionPerformed

    private void txtBuscadorKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtBuscadorKeyReleased
        String nombreEmpresa = txtBuscador.getText();
        String categoria = cbxCategoria.getSelectedItem().toString();
        String sql;
        if (categoria.equals("Ver Todos")) {
            sql = "CALL `buscador_Proveedor`(" +'"' + nombreEmpresa + '"' +",''," + 4 + ")";
        } else {
            sql = "CALL `buscador_Proveedor`(" + '"' + nombreEmpresa + '"' + "," + '"'+categoria+'"' + "," + 1 + ")";
        }
        clsProveedor.mostrarTablaProveedores(tbProveedores, sql);
    }//GEN-LAST:event_txtBuscadorKeyReleased

    private void lblVerProveedorDeshabilitadoMouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblVerProveedorDeshabilitadoMouseMoved
        lblVerProveedorDeshabilitado.setForeground(Color.LIGHT_GRAY);
    }//GEN-LAST:event_lblVerProveedorDeshabilitadoMouseMoved

    private void jPanel4MouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jPanel4MouseMoved
        lblVerProveedorDeshabilitado.setForeground(Color.BLACK);
    }//GEN-LAST:event_jPanel4MouseMoved

    private void lblVerProveedorDeshabilitadoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblVerProveedorDeshabilitadoMouseClicked
        new frmProveedorEliminados(null, true).setVisible(true);
        this.cargarProveedores();
        lblVerProveedorDeshabilitado.setForeground(Color.BLACK);
    }//GEN-LAST:event_lblVerProveedorDeshabilitadoMouseClicked

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(frmProveedor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(frmProveedor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(frmProveedor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(frmProveedor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the dialog */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {

                frmProveedor dialog = new frmProveedor(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAgregarRubro;
    private javax.swing.JButton btnAgregarTelefono;
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnEliminar;
    private javax.swing.JButton btnGuardar;
    private javax.swing.JButton btnModificar;
    private javax.swing.JButton btnNuevo;
    private javax.swing.JComboBox cbxCategoria;
    private javax.swing.JComboBox cbxCiudad;
    public static javax.swing.JComboBox cbxRubro;
    public static javax.swing.JComboBox cbxTelefono;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JLabel lbObligatorio1;
    private javax.swing.JLabel lbObligatorio2;
    private javax.swing.JLabel lblVerProveedorDeshabilitado;
    private org.edisoncor.gui.panel.Panel panel1;
    private javax.swing.JLabel stars1;
    private javax.swing.JLabel stars2;
    private javax.swing.JLabel stars3;
    private javax.swing.JLabel stars4;
    private javax.swing.JLabel stars5;
    private javax.swing.JTable tbProveedores;
    private javax.swing.JTextField txtBuscador;
    private javax.swing.JTextField txtDireccion;
    private javax.swing.JTextField txtEmail;
    private javax.swing.JTextField txtNombre_Contacto;
    private javax.swing.JTextField txtNombre_Empresa;
    private javax.swing.JTextField txtNro_Cuenta;
    // End of variables declaration//GEN-END:variables

    private void cargarProveedores() {
        String sql = "CALL `buscador_Proveedor`("+"'','',"+3+")";
        clsProveedor.mostrarTablaProveedores(tbProveedores, sql);

        sql = "CALL `obtener_listaCategorias`";
        clsCategoria.obtener_listaCategorias(cbxCategoria, sql);
    }

    private void cargarComboBoxRubro() {
        this.eliminarRepetidos();
        for (int i = 0; i < listaRubros.size(); i++) {
            cbxRubro.addItem(listaRubros.get(i));
        }
    }

    private void eliminarRepetidos() {
        int i = 0;
        while (i < listaRubros.size() - 1) {
            int j = i + 1;
            while (j < listaRubros.size()) {
                if (listaRubros.get(i).equals(listaRubros.get(j))) {
                    listaRubros.remove(j);
                } else {
                    j++;
                }
            }
            i++;
        }
    }

    private void borrarCampos() {
        txtNombre_Empresa.setText("");
        txtDireccion.setText("");
        txtNro_Cuenta.setText("");
        txtNombre_Contacto.setText("");
        txtEmail.setText("");
        cbxTelefono.removeAllItems();
        cbxRubro.removeAllItems();
    }

    private void deshabilitarCampos() {
        txtNombre_Empresa.setEnabled(false);
        txtDireccion.setEnabled(false);
        txtEmail.setEnabled(false);
        txtNombre_Contacto.setEnabled(false);
        txtNro_Cuenta.setEnabled(false);
        cbxCiudad.setEnabled(false);
        cbxRubro.setEnabled(false);
        cbxTelefono.setEnabled(false);
        btnAgregarTelefono.setEnabled(false);
        btnAgregarRubro.setEnabled(false);
        btnModificar.setEnabled(false);
        btnGuardar.setEnabled(false);
        btnNuevo.setEnabled(true);
        btnEliminar.setEnabled(false);
        btnCancelar.setEnabled(false);
        lbObligatorio1.setVisible(false);
        lbObligatorio2.setVisible(false);
    }

    private void habilitarCampos() {
        txtNombre_Empresa.setEnabled(true);
        txtDireccion.setEnabled(true);
        txtEmail.setEnabled(true);
        txtNombre_Contacto.setEnabled(true);
        txtNro_Cuenta.setEnabled(true);
        cbxCiudad.setEnabled(true);
        cbxRubro.setEnabled(true);
        cbxTelefono.setEnabled(true);
        btnAgregarTelefono.setEnabled(true);
        btnAgregarRubro.setEnabled(true);
        btnModificar.setEnabled(false);
        btnGuardar.setEnabled(true);
        btnNuevo.setEnabled(false);
        btnCancelar.setEnabled(true);

    }

    private void pintaEstrellas(float valor) {

        if (valor > 0 && valor <= 0.5) {
            stars1.setIcon(imageIcon_medium);
            stars2.setIcon(imageIcon_empty);
            stars3.setIcon(imageIcon_empty);
            stars4.setIcon(imageIcon_empty);
            stars5.setIcon(imageIcon_empty);
        } else {
            if (valor > 0.5 && valor <= 1) {
                stars1.setIcon(imageIcon_complete);
                stars2.setIcon(imageIcon_empty);
                stars3.setIcon(imageIcon_empty);
                stars4.setIcon(imageIcon_empty);
                stars5.setIcon(imageIcon_empty);
            } else {
                if (valor > 1 && valor <= 1.5) {
                    stars1.setIcon(imageIcon_complete);
                    stars2.setIcon(imageIcon_medium);
                    stars3.setIcon(imageIcon_empty);
                    stars4.setIcon(imageIcon_empty);
                    stars5.setIcon(imageIcon_empty);
                } else {
                    if (valor > 1.5 && valor <= 2) {
                        stars1.setIcon(imageIcon_complete);
                        stars2.setIcon(imageIcon_complete);
                        stars3.setIcon(imageIcon_empty);
                        stars4.setIcon(imageIcon_empty);
                        stars5.setIcon(imageIcon_empty);
                    } else {
                        if (valor > 2 && valor <= 2.5) {
                            stars1.setIcon(imageIcon_complete);
                            stars2.setIcon(imageIcon_complete);
                            stars3.setIcon(imageIcon_medium);
                            stars4.setIcon(imageIcon_empty);
                            stars5.setIcon(imageIcon_empty);
                        } else {
                            if (valor > 2.5 && valor <= 3) {
                                stars1.setIcon(imageIcon_complete);
                                stars2.setIcon(imageIcon_complete);
                                stars3.setIcon(imageIcon_complete);
                                stars4.setIcon(imageIcon_empty);
                                stars5.setIcon(imageIcon_empty);
                            } else {
                                if (valor > 3 && valor <= 3.5) {
                                    stars1.setIcon(imageIcon_complete);
                                    stars2.setIcon(imageIcon_complete);
                                    stars3.setIcon(imageIcon_complete);
                                    stars4.setIcon(imageIcon_medium);
                                    stars5.setIcon(imageIcon_empty);
                                } else {
                                    if (valor > 3.5 && valor <= 4) {
                                        stars1.setIcon(imageIcon_complete);
                                        stars2.setIcon(imageIcon_complete);
                                        stars3.setIcon(imageIcon_complete);
                                        stars4.setIcon(imageIcon_complete);
                                        stars5.setIcon(imageIcon_empty);
                                    } else {
                                        if (valor > 4 && valor <= 4.5) {
                                            stars1.setIcon(imageIcon_complete);
                                            stars2.setIcon(imageIcon_complete);
                                            stars3.setIcon(imageIcon_complete);
                                            stars4.setIcon(imageIcon_complete);
                                            stars5.setIcon(imageIcon_medium);
                                        } else {
                                            if (valor > 4.5 && valor <= 5) {
                                                stars1.setIcon(imageIcon_complete);
                                                stars2.setIcon(imageIcon_complete);
                                                stars3.setIcon(imageIcon_complete);
                                                stars4.setIcon(imageIcon_complete);
                                                stars5.setIcon(imageIcon_complete);
                                            } else {
                                                stars1.setIcon(imageIcon_empty);
                                                stars2.setIcon(imageIcon_empty);
                                                stars3.setIcon(imageIcon_empty);
                                                stars4.setIcon(imageIcon_empty);
                                                stars5.setIcon(imageIcon_empty);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    private void agregar_aTablaProveedores(int idProveedor, String nombreEmpres, String direccion, String ciudad, String email, String nroCuenta, String nombContacto, float valoracion) {
        //agregar a la tabla
        Object[] prov = new Object[8];
        prov[0] = idProveedor;
        prov[1] = nombreEmpres;
        prov[2] = direccion;
        prov[3] = ciudad;
        prov[4] = email;
        prov[5] = nroCuenta;
        prov[6] = nombContacto;
        prov[7] = valoracion;
        DefaultTableModel dtmProveedores = (DefaultTableModel) tbProveedores.getModel();
        dtmProveedores.addRow(prov);
    }
}
